package chen.web.search;

import org.apache.lucene.document.Document;
import org.apache.lucene.document.Field;

import chen.web.forum.Subject;

public class SubjectDocument {

	public static final String Field_Title = "title";
	public static final String Field_Content= "content";
	public static final String Field_Id = "id";
	
	public Document getDocument(Subject subject){
		Document document = new Document(); 
		Field titleField = new Field(Field_Title, subject.getTitle(), Field.Store.YES, Field.Index.ANALYZED);
		Field contentField = new Field(Field_Content, subject.getContent(), Field.Store.YES, Field.Index.ANALYZED);
		Field idField = new Field(Field_Id, String.valueOf(subject.getId()), Field.Store.YES, Field.Index.NOT_ANALYZED);
		document.add(titleField);
		document.add(contentField);
		document.add(idField);
		return document;
	}
}
